<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <base href="<%=basePath%>">   
    <title>查询成绩</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta charset="utf-8">
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" >
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>	
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>
  
  <body>
       <nav class="navbar navbar-default navbar-static-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          </button>
          <a class="navbar-brand" href="#">学生人数统计</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            
            <li><a href="search/students"><span class="glyphicon glyphicon-list-alt"></span>学生信息</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span>时间查询</a>
              <ul class="dropdown-menu">
                <li><a href="search/searchDay?day=0">查询当天</a></li>
                <li><a href="search/searchDay?day=1">查询近两天</a></li>
                <li><a href="search/searchDay?day=364">查询一年</a></li>          
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span>学制查询</a>
              <ul class="dropdown-menu">
                <li><a href="search/searchLength?length=3">三年</a></li>
                <li><a href="search/searchLength?length=4">四年</a></li>
                <li><a href="search/searchLength?length=5">五年</a></li>          
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" id="searchDeptAndMajor" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span>系别查询</a>
              <ul id="searchDeptAndMajorUl" class="dropdown-menu">
                                      
              </ul>
            </li>
          </ul>
               <form class="navbar-form navbar-left" role="search" action="search/searchById" method="post">
			  <div class="form-group">
			    <input type="text" name="id" class="form-control" placeholder="输入学生id">
			  </div>
			  <button type="submit" class="btn btn-info">学生ID</button>
		        </form>
		        
			  <form class="navbar-form navbar-left" role="search" action="search/searchByDept" method="post">
				  <div class="form-group">
				    <input type="text" name="deptName" class="form-control" placeholder="输入系部名称">
				  </div>
				  <button type="submit" class="btn btn-info">系部名称</button>
			  </form>			  
			  <form class="navbar-form navbar-right" role="search" action="search/searchByDept" method="post">
				  <button class="btn btn-info" type="button" disabled="disabled">
				  学生总数 <span class="badge">${pageInfo.total}</span>
			      </button>				      	  
			  </form>			  	  		
        </div>
      </div>
    </nav>		
		 <div class="row">
		   <div class="container-fluid">
			 <table class="table table-hover">	  
			  <tr>
			       <th>学生编号</th>
			       <th>学号</th>
			       <th>姓名</th>
			       <th>性别</th>
			       <th>出生年月日</th>
			       <th> 籍贯</th>
			       <th>民族</th>
			       <th>身份证</th>		       
			       <th>学院</th>
			       <th>系别</th>		       
			       <th>系别</th>
			       <th>教育层次</th>   
			       <th>学制</th>		       
			       <th>形式</th>
			       <th>入学日期</th>
			       <th>毕业日期</th>    
			  </tr>
				  <c:forEach items="${pageInfo.list}" var="student">				 
					   <tr>
							<td>${student.stuid}</td>
							<td>${student.stuno}</td>
							<td>${student.stuname}</td>
							<td>${student.stusex}</td>
							
							<td><fmt:formatDate value="${student.stubirth}" pattern="yyyy-MM-dd"/></td>
							<td>${student.address}</td>
							<td>${student.nation}</td>
							<td>${student.identification}</td>
							<td>${student.school}</td>
							<td>${student.department}</td>
							<td>${student.classid}</td>
							<td>${student.arrangement}</td>		      
							<td>${student.length}</td>
							<td>${student.form}</td>
							<td><fmt:formatDate value="${student.enrolment}" pattern="yyyy-MM-dd"/></td>
							<td><fmt:formatDate value="${student.graduation}" pattern="yyyy-MM-dd"/></td>	      
					   </tr>
				  </c:forEach>
			</table>
		    </div>
		 </div>
		  <!--显示分页信息-->  
		    <div class="row">  
		        <!--文字信息-->  
		        <div class="col-md-6">  
		                            当前第 <span class="label label-info">${pageInfo.pageNum}</span>页.
		                            总共<span class="label label-info"> ${pageInfo.pages} </span>页.
		                            一共 <span class="label label-info">${pageInfo.total} </span>条记录  
		        </div>  
		        <!--点击分页-->  
		        <div class="col-md-6">  
		            <nav aria-label="Page navigation">  
		                <ul class="pagination">  
		                      
		                    <li><a href="search/students?pn=1">首页</a></li>  
		                      
		                    <!--上一页-->  
		                    <li>  
		                        <c:if test="${pageInfo.hasPreviousPage}">  
		                            <a href="search/students?pn=${pageInfo.pageNum-1}" aria-label="Previous">  
		                                <span aria-hidden="true">«</span>  
		                            </a>  
		                        </c:if>  
		                    </li>  
		  
		                    <!--循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接-->  
		                    <c:forEach items="${pageInfo.navigatepageNums}" var="page_num">  
		                        <c:if test="${page_num == pageInfo.pageNum}">  
		                            <li class="active"><a href="#">${page_num}</a></li>  
		                        </c:if>  
		                        <c:if test="${page_num != pageInfo.pageNum}">  
		                            <li><a href="search/students?pn=${page_num}">${page_num}</a></li>  
		                        </c:if>  
		                    </c:forEach>  		  
		                    <!--下一页-->  
		                    <li>  
		                        <c:if test="${pageInfo.hasNextPage}">  
		                            <a href="search/students?pn=${pageInfo.pageNum+1}"  
		                               aria-label="Next">  
		                                <span aria-hidden="true">»</span>  
		                            </a>  
		                        </c:if>  
		                    </li>  		                      
		                    <li><a href="search/students?pn=${pageInfo.pages}">尾页</a></li>  
		                </ul>  
		            </nav>  
		        </div>  
		    </div> 
		    <script type="text/javascript">
	     $("#searchDeptAndMajor").click(function(){
		          $('#searchDeptAndMajorUl').html("");        
			          $.ajax({
						   type: "POST",
						   url: "search/searchDeptAndMajor",			
						   success: function(msg){
						        var item;				      				     				         
									$.each(msg,function(i,result){									  					       						    
									     if(result.fatherid===0){
									         item="<li class='"+i+"'>"+"<a href='"+"search/searchMajor?fatherid="+i+"'>"+result.mname+"</a>"+"</li>"; 									         					         
									         $('#searchDeptAndMajorUl').append(item);							         							         						 	
									     }								    								     						    							   			    						    												
									});											 
						   }				   
					  });	     
	      });	      
	    	      	     
	</script>
  </body>
</html>
